package bean;



/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */



import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;

/**
 *
 * @author akay
 */
public class DBGetData {

    public DBGetData() {
    }

    public ArrayList<Location> getLocations() {
        String query;
        ResultSet resultSet;
        ArrayList<Location> locations = new ArrayList<Location>();
        DBConncetion dBConncetion = new DBConncetion();
        Connection connect = dBConncetion.getConnect();
        query = "SELECT * FROM location";

        try {
           Statement statement = (Statement) connect.createStatement();
            resultSet = statement.executeQuery(query);

            while (resultSet.next()) {
               locations.add(new Location(resultSet.getInt(1), resultSet.getString(2), resultSet.getString(3), resultSet.getString(4), resultSet.getDate(5)));
              }

        } catch (SQLException e) {
            System.err.println("veri tabanindan veri alinamadi");
            e.printStackTrace();

        }
        dBConncetion.closeConnect(connect);
        return locations;

    }
}
